<template>
  <div>
    <el-row>
      <el-col :span="6">
        <ItemList :value="items"></ItemList>
      </el-col>
      <el-col style="margin-left: 50px;" :span="15">
        <ItemDetail :value="itemDetails"></ItemDetail>
      </el-col>
      <el-col :span="2">
        <ItemCategory @categoryChange="categoryChange"></ItemCategory>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import ItemList from '@/components/Desk/ItemList'
import ItemCategory from '@/components/Desk/ItemCategory'
import ItemDetail from '@/components/Desk/ItemDetail'
import { goodsList } from '@/api/shop/goods'
import { orderList } from '@/api/shop/order'

export default {
  name: 'DeskInfo',
  components: {
    ItemList,
    ItemCategory,
    ItemDetail
  },
  props: {
    desk: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      items: [],
      itemDetails:[],
    }
  },
  computed: {
    deskInfo() {
      return this.desk
    }
  },
  methods:{
    categoryChange(categoryId){
      goodsList({categoryId}).then(res=>{
        this.itemDetails = res.rows;
      })
    }
  },
  created() {
    orderList({ tableNum:this.desk.tableNum}).then(res=>{
      console.log(res)
    })
  }
}
</script>

<style scoped>
</style>
